package ${package}.entity.demo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * User entity.
 * 用MyEclipse自动生成的JPA annotation注明ORM关系.
 * 用@NamedQueries 定义命名JPQL查询语句.
 * 用@Cache注明Hibernate缓存策略.
 * 
 * @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "USERS")//Table名与类名不同时进行注释
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@NamedQueries( { @NamedQuery(name = "User.countByAuth", query = "SELECT COUNT(user) FROM User user where user.loginName=? and password=?") })
public class User {

	// Fields

	private Integer id;

	private String loginName;

	private String password;


	// Constructors

	/** default constructor */
	public User() {
	}

	/** minimal constructor */
	public User(Integer id, String loginName) {
		this.id = id;
		this.loginName = loginName;
	}

	// Property accessors
	@Id //主键及生成策略注释
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(name = "PASSWORD") //Column名与属性名不同时进行注释
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getLoginName() {
		return this.loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	
	@Override
	public String toString(){
		return ToStringBuilder.reflectionToString(this);
	}
}